import com.alibaba.fastjson.JSON;
import com.qian.api.ddj.util.SignUtils;
import com.yaowk.api.utils.HttpUtils;
import org.apache.commons.codec.digest.DigestUtils;
import org.junit.Test;

import java.util.Map;
import java.util.TreeMap;

public class PayTest01 {

    String userId = "M00000046";
    String key = "6E3D333E787F490EBFE7E2487B8CFB6B";

    @Test
    public void pay() {
        Map<String, String> map = new TreeMap<>();
        map.put("merchNo", userId);
        map.put("orderNo", System.currentTimeMillis() + "");
        map.put("transAmount", "1000");
        map.put("productName", "productName");
        map.put("notifyUrl", "http://www.baidu.com");
        map.put("sign", DigestUtils.md5Hex(SignUtils.params(map) + key));
        String body = JSON.toJSONString(map);
        System.out.println(body);
//        String receive = HttpUtils.post("http://47.94.208.216:8080/app/doWXPay.do", body);
        String receive = HttpUtils.post("http://47.94.208.216:8080/app/doQQPay.do", body);
        System.out.println(receive);
    }

    @Test
    public void cash() {
        Map<String, String> map = new TreeMap<>();
        map.put("merchNo", userId);
        map.put("settleNo", System.currentTimeMillis() + "");
        map.put("settleAmount", "1000");
        map.put("accIdentity", "productName");
        map.put("accType", "productName");
        map.put("accName", "productName");
        map.put("accNo", "productName");
        map.put("accPhone", "productName");
        map.put("unionCode", "productName");
        map.put("bankCode", "productName");
        map.put("notifyUrl", "http://www.baidu.com");
        map.put("sign", DigestUtils.md5Hex(SignUtils.params(map) + key));
        String body = JSON.toJSONString(map);
        System.out.println(body);
//        String receive = HttpUtils.post("http://47.94.208.216:8080/app/doWXPay.do", body);
        String receive = HttpUtils.post("http://47.94.208.216:8080/app/doWithdrawSettle.do", body);
        System.out.println(receive);
    }

    @Test
    public void query() {
        Map<String, String> map = new TreeMap<>();
        map.put("merchNo", userId);
        map.put("settleType", "D0");
        map.put("sign", DigestUtils.md5Hex(SignUtils.params(map) + key));
        String body = JSON.toJSONString(map);
        System.out.println(body);
//        String receive = HttpUtils.post("http://47.94.208.216:8080/app/doWXPay.do", body);
        String receive = HttpUtils.post("http://47.94.208.216:8080/app/accSingleMax.do", body);
        System.out.println(receive);
    }
}
